<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />
		<title>投放明细</title>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
		<meta http-equiv="description" content="This is my page" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/css/common.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/css/tag.css" />
		<link rel="stylesheet" type="text/css" 
			href="<%=path%>/js/jquery-ui-1.8.21.custom/css/smoothness/jquery-ui-1.8.21.custom.css" />
		<script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript"
			src="<%=path%>/js/jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min.js"></script>
		<script type="text/javascript" src="<%=path%>/js/form.js"></script>
		<script type="text/javascript" src="<%=path%>/js/public.js"></script>
		<script type="text/javascript"
			src="<%=path%>/js/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript">
			$(function() {
				$("#showMediumStatus").val($("#mediumStatus").find("option:selected").text());
				
				//
				$("#basicSubmitButton").click(function(){
					if($("#arrangeTime").val() == ""){
						alert("排期时间不能为空！");
					}else if($("#mediumOrientDiscount").val() == ""){
						alert("定向折扣不能为空！");
					}else if($("#mediumStatus").val() == ""){
						alert("资源占用状态未选择！");
					}else{
						var oldMediumOrientDiscount = $("#oldMediumOrientDiscount").val();
						var newMediumOrientDiscount = $("#mediumOrientDiscount").val();
						if(oldMediumOrientDiscount != newMediumOrientDiscount)
						{
						   if(confirm("定向折扣修改后，需要重新设置费用信息，确认修改吗？"))
						   {
						      formSubmit('basicForm', 'initBasicInfo', 'editBasicInfoToDelCharges.action', refrashChargeByBasic);
						   }
						}
						else
						{
						   formSubmit('basicForm', 'initBasicInfo', 'editBasicInfo.action', showResult);
						}
					}
				});
				//
				$("#mediumOrientDiscount").blur(function(){
					var mediumOrientDiscount = $(this).val();
					var reg = /^\d*?$/;
					//if(reg.test(mediumOrientDiscount)){
					if(isFloat(mediumOrientDiscount)){
						if(mediumOrientDiscount > 100 || mediumOrientDiscount < 0){
							alert("定向折扣必须为0~100以内数字！");
							$(this).val("");
						}
					}else{
						alert("定向折扣必须为0~100以内数字！");
						$(this).val("");
					}
				});
			});
			
			//判断是否为浮点数
			function isFloat(oNum) 
			{ 
				 if(oNum == 0)
				 {
				    return true;
				 }
				 if(!oNum) return false;
				 var strP=/^\d+(\.\d+)?$/;
				 if(!strP.test(oNum)) return false;
				 try{
				 	if(parseFloat(oNum)!=oNum) return false;
				 }catch(ex){
				   return false;
				 }
				 return true;
			}
			
			function refrashChargeByBasic(html)
			{
			   alert('操作成功！');
			   loadPage('initCharge.action', {'proMedID':$("#chkProMedID").val()}, 'initCharge');
			}
		</script>
	</head>

	<body>
		<input type="hidden" name="chkProMedID" id="chkProMedID" value="${castDetail.proMedID}"/>
		<input type="hidden" name="oldMediumOrientDiscount" id="oldMediumOrientDiscount" value="${castDetail.mediumOrientDiscount}"/>
		<form id="basicForm" method="post">
			<table class="table_add" style="width:100%;">
				<tr>
					<th style="width:150px;">项目名称：</th>
					<td style="width:225px;">
						<input type="text" class="text" style="width:225px;" disabled="disabled" value="${castDetail.projectName }" />
					 	<input name="castDetail.proMedID" type="hidden" class="text" style="width:225px;" value="${castDetail.proMedID }" />
					</td>
					<th style="width:189px;">排期时间：</th>
					<td>
						<input id="arrangeTime" name="castDetail.arrangeTime" type="text" class="text Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM'})" style="width:225px;" readonly="readonly" value="${castDetail.arrangeTime }" />
					</td>
					<td>
						<input id="basicSubmitButton" type="button" class="btn-title" value="保存" />
					</td>
				</tr>
				<tr>
					<th style="width:150px;">投放媒体：</th>
					<td style="width:225px;">
						<input type="text" class="text" style="width:225px;" disabled="disabled" value="${castDetail.mediaName }" />
					</td>
					<th style="width:189px;">投放刊例：</th>
					<td>
						<input type="text" class="text" style="width:225px;" disabled="disabled" value="${castDetail.mediumName }" />
					</td>
				</tr>
				<tr>
					<th style="width:150px;">定向折扣(%)：</th>
					<td style="width:225px;">
						<input id="mediumOrientDiscount" name="castDetail.mediumOrientDiscount" type="text" class="text" style="width:225px;" value="${castDetail.mediumOrientDiscount }" />
					</td>
					<th style="width:189px;">资源占用状态：</th>
					<td>
						<input type="text" class="text" style="width:225px;" disabled="disabled" id="showMediumStatus"/>
						<s:select  value="castDetail.mediumStatus" id="mediumStatus" name="castDetail.mediumStatus" cssStyle="width:227px; display:none;"
						list="mediumStatusSelect" listKey="id" listValue="datavalue" headerKey="" headerValue="--资源占用状态--" ></s:select>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
